#include"UDPServer.hpp"

#include"chat_room.hpp"

using namespace ChatRoomMudule;

int main(int argc,char* argv[])
{
    if(argc!=2)//判断是否满足执行需求
    {
        cout<<"udp_server port"<<endl;
        return 0;
    }
    ChatRoom char_room;

    u_int16_t port=atoi(argv[1]);
    UdpServer server(port);

    //注册函数
    server.Registration([&char_room](int sockfd,const string &msg){char_room.Broadcast(sockfd,msg);},
    [&char_room](const struct sockaddr_in &addr){return char_room.InsetUser(addr);},
    [&char_room](const struct sockaddr_in &addr){return char_room.isExist(addr);});


    server.Start();//启动服务器

    server.Stop();

    return 0;
}